import sys
import turtle

# print(sys.version_info)
# print(sys.version)

a = "zhangsan"
b = 19
c = 1.1
d = 1 + 3j
e = True
print(type(a))
print(type(b))
print(type(c))
print(type(d))
print(type(e))

a = "1"
b = "1.1"
c = 5
d = "abcd"
e = "a"
print(int(a))
print(float(b))
print(str(c))
print(chr(c))
print(ord(e))

# a = int(input('a='))
# print(a)

for i in range(1, 101, 2):
    print("i=%.f" % i)

a = 5
while a > 0:
    a = a - 1
    print(a)


# 定义函数
def my_func():
    pass


print("---------------------------")


def add(a=0, b=0, c=0):
    return a + b + c


print(add())
print(add(1))
print(add(1, 2))
print(add(1, 2, 3))
print("---------------------------")


def add1(*args):
    total = 0
    for t in args:
        total += t
    return total


print(add1(1, 2, 3, 4, 5, 6, 7))
print("---------------------------")

from a import a_func

a = a_func()

from b import a_func

b = a_func()

import a as a1

a1.a_func()
import b as b1

b1.a_func()
print("---------------------------")

def foo():
    # global a 
    a = 10
    print(a)
    def bar():
        print(a)
    bar()

if __name__ == '__main__':
    # a1.a_func()
    # b1.a_func()
    a = 0
    foo()
    print(a)
    
print("---------------------------")



str1 = 'hello, world!'
# 通过内置函数len计算字符串的长度
print(len(str1)) # 13
# 获得字符串首字母大写的拷贝
print(str1.capitalize()) # Hello, world!
# 获得字符串每个单词首字母大写的拷贝
print(str1.title()) # Hello, World!
# 获得字符串变大写后的拷贝
print(str1.upper()) # HELLO, WORLD!
# 从字符串中查找子串所在位置
print(str1.find('or')) # 8
print(str1.find('shit')) # -1
# 与find类似但找不到子串时会引发异常
# print(str1.index('or'))
# print(str1.index('shit'))
# 检查字符串是否以指定的字符串开头
print(str1.startswith('He')) # False
print(str1.startswith('hel')) # True
# 检查字符串是否以指定的字符串结尾
print(str1.endswith('!')) # True
# 将字符串以指定的宽度居中并在两侧填充指定的字符
print(str1.center(50, '*'))
# 将字符串以指定的宽度靠右放置左侧填充指定的字符
print(str1.rjust(50, ' '))
str2 = 'abc123456'
# 检查字符串是否由数字构成
print(str2.isdigit())  # False
# 检查字符串是否以字母构成
print(str2.isalpha())  # False
# 检查字符串是否以数字和字母构成
print(str2.isalnum())  # True
str3 = '  jackfrued@126.com '
print(str3)
# 获得字符串修剪左右两侧空格之后的拷贝
print(str3.strip())